package com.wondertek.poms.core.service.impl;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wondertek.poms.common.constant.Constants;
import com.wondertek.poms.common.service.impl.ServiceImpl;
import com.wondertek.poms.common.utils.CopyUtils;
import com.wondertek.poms.core.service.IPcImageTaskService;
import com.wondertek.poms.dao.po.PcImageTask;

/**
 * <p><b>PcImageTaskServiceImpl Description:</b> 转图任务表 service层实现 </p>
 * @author 窦再兴
 * <p><b>DATE</b> 2020-10-28 11:14:09</p>
 */
@Service
@Scope("prototype")
public class PcImageTaskServiceImpl extends ServiceImpl<PcImageTask, Long> implements IPcImageTaskService {
	@Override
	@Transactional
	public PcImageTask deleteLogic(Long id) {
		PcImageTask cp = jpaRepository.getOne(id);
		PcImageTask.putTimeAndUser(cp);
		cp.setDeleted(Constants.DELETE_1);
		jpaRepository.save(cp);
		return cp;
	}

	@Override
	@Transactional
	public PcImageTask merge(PcImageTask model) {
		//TODO (如果报错删除报错行)
		PcImageTask.putTimeAndUser(model);
		PcImageTask dbo = jpaRepository.getOne(model.getId());
		CopyUtils.copyProperties(model, dbo);
		return jpaRepository.save(dbo);
	}
}